package au.com.langdale.gwt.client.model;

/**
 * Base for all Boolean properties.  Concrete properties must 
 * provide _get(), _set(), and getName().
 * 
 * @author adv
 *
 */
public abstract class BooleanProperty extends Property {

	public BooleanProperty() {
		// serializable ctor
	}
	
	protected abstract Boolean _get(Object model);
	protected abstract void _set(Object model, Boolean value);

	public String get(Object model) {
		Boolean value = _get(model);
		if( value != null)
			return value.toString();
		else
			return "";

	}

	public void set(Object model, String value) {
		_set(model, Boolean.valueOf((value)));
	}
	
	public boolean isSet(Object model) {
		Boolean value = _get(model);
		return value != null && value.booleanValue();
	}

	public void set(Object model, boolean value) {
		_set(model, Boolean.valueOf(value));
	}
	
	public int getLength() {
		return 5;
	}
	
	public String getStyleName() {
		return "boolean-field";
	}
}
